import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
import java.util.LinkedList;
import java.util.Scanner;

/**
 * Created by IntelliJ IDEA.
 * User: User
 * Date: 20.08.12
 * Time: 9:42
 * To change this template use File | Settings | File Templates.
 */
public class FileFRApp {
    public static void main(String[] args) throws IOException {

        Scanner scan = new Scanner(System.in);
        String key;
        LinkedList<File> paths = new LinkedList<File>();
        ArrayList<String> als;
        System.out.println("Write path to directory");
        File targetDir = new File(scan.nextLine());
        //File targetDir = new File("D:\\fortests");
        File[] targetFiles = targetDir.listFiles();
        for (int i = 0; i < targetFiles.length; i++) {
            paths.add(targetFiles[i]);
        }
        String[] s = new String[paths.size()];
        /*s[0] = "D:\\fortests\\1.txt";

      s[1] = "D:\\fortests\\2.txt";*/
        for (int i = 0; i < paths.size(); i++) {
            s[i] = paths.get(i).getAbsolutePath();
        }

        FileActor actor = new FileActor(s);

        System.out.println("Write one of keys");
        while (true) {
            key = scan.nextLine();
            if (key.equals("exit")) break;
            System.out.println("Searching key=" + key);
            als = actor.get(key);
            for (int i = 0; i < als.size(); i++) {
                System.out.println(als.get(i));
            }


        }
    }


}
